import { Button, Modal } from 'antd';
import './style/index';

export interface Props {
  visible?: boolean;
  type?: 'error' | 'default';
  content?: string;
  footer?: any;
  onOk?: (...args: any[]) => any;
  onCancel?: (...args: any[]) => any;
}

function TipModal(props: Props) {
  const { visible, content, footer, type = 'default' } = props;
  const modalProps = {
    visible,
    className: 'stong-tip-modal',
    title: '提示',
    width: 420,
    footer: footer || [
      <Button onClick={props.onCancel}>取消</Button>,
      <Button danger={type === 'error'} type="primary" onClick={props.onOk}>
        确认
      </Button>,
    ],
    onOk: props.onOk,
    onCancel: props.onCancel,
  };
  return (
    <Modal {...modalProps}>
      <div className="modals-body">
        <div className="modals-icon"></div>
        <span className="modals-content">{content}</span>
      </div>
    </Modal>
  );
}

export default TipModal;
